// 2010-03-26 - M. Caputo

#include <QtOpenGL>

#include "DotMode.h"

QString DotMode::name()
{
	return tr("Dot Mode");
}

void DotMode::setSettings()
{
	glEnable(GL_DEPTH_TEST);
	glPointSize(2.0);
}

void DotMode::unsetSettings()
{
	glPointSize(1.0);
	glDisable(GL_DEPTH_TEST);
}

void DotMode::draw(IScene *scene, const QColor & defaultColor)
{
	glColor3f(
		defaultColor.redF(),
		defaultColor.greenF(),
		defaultColor.blueF()
	);
	
	glBegin( GL_POINTS );
	int cp = scene->polygonsCount();
	for(int i=0; i<cp; i++) {
		CPolygon poly = scene->polygon(i);
		int cv = poly.verticesCount();
		for(int j=0; j<cv; j++) {
			CVertex vert = poly.vertex(j);
			const float *data = vert.vertex();
			glVertex3f(
				data[0],
				data[1],
				data[2]
			); 
		}
	}
	glEnd();
}
